//
//  TTLiveDetailedResidentView.swift
//  TTProduct
//
//  Created by Toj on 3/23/21.
//  Copyright © 2021 TTProduct. All rights reserved.
//

import Cocoa

class TTLiveDetailedResidentView: NSView {
    
    // 网络状态
    lazy var networkImageView: NSImageView = {
        let view = NSImageView()
        view.image = NSImage(named: "liveNetworkLevel4")
        return view
    }()
    
    // 昵称
    lazy var nicknameLabel: TTLabel = {
        let view = TTLabel()
        view.lineBreakMode = .byTruncatingTail
        view.textColor = NSColor.init(hexColor: "#E5E1E2")
        view.font = NSFont.systemFont(ofSize: 11)
        return view
    }()
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        
        setupMakeAddSubviews()
        setupMakeUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layout() {
        super.layout()
        setupMakeLayoutSubviews()
    }
}

extension TTLiveDetailedResidentView {
    
    private func setupMakeAddSubviews() {
        addSubview(networkImageView)
        addSubview(nicknameLabel)
    }
    
    private func setupMakeLayoutSubviews() {
        
        networkImageView.snp.remakeConstraints { (make) in
            make.left.equalTo(5)
            make.centerY.equalTo(self)
            make.width.equalTo(18)
            make.height.equalTo(13)
        }

        nicknameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(networkImageView.snp.right).offset(5)
            make.centerY.equalTo(self)
            make.right.equalTo(snp.right).offset(-2)
        }
    }
    
    private func setupMakeUI() {
        tt_cornerRadius(3)
        tt_backgroundColor = NSColor.black.tt_alpha(0.4)
    }
}
